package by.pavlyukevich.paymentsystem.datamodel;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import by.pavlyukevich.paymentsystem.datamodel.card.Card;
import by.pavlyukevich.paymentsystem.datamodel.payment.Payment;

@Entity
public class Transaction extends AbstractEntity<Integer> {

	@ManyToOne(fetch = FetchType.LAZY)
	@NotNull
	private Account senderAccount;

	@ManyToOne(fetch = FetchType.LAZY)
	private Card senderCard;

	@ManyToOne(fetch = FetchType.LAZY)
	@NotNull
	private Account payeeAccount;

	@ManyToOne(fetch = FetchType.LAZY)
	private Payment payment;

	@Column
	@Min(value = 1)
	@NotNull
	private Double amount;

	@Column
	@NotNull
	private Date date;

	public Account getSenderAccount() {
		return senderAccount;
	}

	public void setSenderAccount(Account senderAccount) {
		this.senderAccount = senderAccount;
	}

	public Card getSenderCard() {
		return senderCard;
	}

	public void setSenderCard(Card senderCard) {
		this.senderCard = senderCard;
	}

	public Account getPayeeAccount() {
		return payeeAccount;
	}

	public void setPayeeAccount(Account payeeAccount) {
		this.payeeAccount = payeeAccount;
	}

	public Payment getPayment() {
		return payment;
	}

	public void setPayment(Payment payment) {
		this.payment = payment;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

}
